package Demo1;

import java.util.Arrays;
import java.util.Scanner;

//https://www.nowcoder.com/questionTerminal/6736cc3ffd1444a4a0057dee89be789b
//组队竞赛
//测试用例不能去全部通过的原因是数组和结果必须全是long类型
public class TestDemo1 {
    public static void main(String[] args) {
        //1.输入有几组队伍，默认每组队伍有三个
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        //2.对队伍的个数*3 将此数组进行排序
        long[] arr = new long[n*3];
        //循环输入队伍的成绩
        for (int i = 0; i < arr.length; i++) {
            arr[i] = scanner.nextLong();
        }
        Arrays.sort(arr);
        //3.将排序好的数组按照1 2 3 4 5 6 7 8 9
        //3.1 从后面的倒数第二个开始取数  取n组队伍次
        long ret = 0;
        int index = arr.length-2;
        for (int i = 0; i < n; i++) {
            ret+=arr[index];
            index-=2;
        }
        System.out.println(ret);
    }
}
